﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<%@ include file="../admin/top.jsp"%>
</head>
<body>
	<table id="user_table"></table>
	<div id="user_toolbar">
		<a href="#" id="user_add_btn" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">新增</a>
		<a href="#" id="user_remove_btn" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'">删除</a>
		<a href="#" id="user_edit_btn" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">修改</a>
		<a href="#" id="user_set_btn" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-hamburg-suppliers'">用户角色</a>
	</div>
	<script type="text/javascript">
		$(function(){
			$('#user_table').datagrid({
				url:"${ctx}/datagrid/user/listPage",
				singleSelect:true,
				fitColumns:true,
				fit:true,
				toolbar:"#user_toolbar",
				pagination:true,
			    columns: [[
			    	{field : 'id',checkbox : true}, 
			    	{field : 'userName',title : '帐号',sortable : true,width : 100}, 
			    	{field : 'name',title : '昵称',sortable : true,width : 100},
			    	{field : 'gender',title : '性别',sortable : true,formatter : function(value, row, index) {
							return value == 'M' ? '男' : '女';
						}
			    	}, 
					{field : 'email',title : 'email',sortable : true,width : 100}, 
					{field : 'phone',title : '电话',sortable : true,width : 100},
					{field : 'roles',title : '权限',width : 100,formatter:function(value,rowData,res){
							var roles = "";
							if(rowData.roles){
								for(var a=0;a<rowData.roles.length;a++){
									var role = rowData.roles[a];
									roles = roles+role.name+(a<(rowData.roles.length-1)?',':'');
								}
							}
							return roles;
						}
					}]]
			});
			$("#user_add_btn").bind("click",function(){
				top.$.WindowView({
		    		title:"新增用户",
		    		href:"${ctx}/page/system-user-user_add",
		    		action:"${ctx}/post/user/add",
					width:500,
					height:500,
		    		view:window,
		    		buttonShow:true
		    	});
			});
		});
		function reload(){
			var queryParams = $("#user_table").datagrid('options').queryParams;
			 $("#user_table").datagrid('reload',queryParams);
		}
	</script>
</body>
</html>